package com.hqyj.controller;


import com.hqyj.pojo.Tabless;
import com.hqyj.service.ITablessService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;

/**
 * <p>
 * 桌位表 前端控制器
 * </p>
 *
 * @author rock
 * @since 2021-10-21
 */
@RestController
@RequestMapping("/tabless")
public class TablessController {

    @Autowired
    ITablessService tablessService;

    @RequestMapping("/tablessList")
    public HashMap<String,Object> tablessList(Tabless tabless){
        HashMap<String,Object> date = tablessService.queryAll(tabless);
        return date;

    }

    @RequestMapping("/update")
    public HashMap<String,Object> update(Tabless tabless){
        int num = tablessService.updateByTable(tabless);
        HashMap<String,Object> map = new HashMap<>();
        if(num>0){
            return tablessList(new Tabless());
        }else {
            map.put("info","保存失败");
            return map;
        }
    }

    @RequestMapping("/add")
    public HashMap<String,Object> add(Tabless tabless){
        HashMap<String,Object> map = new HashMap<>();
        int num =  tablessService.addTabless(tabless);
        if(num>0){
            return tablessList(new Tabless());
        }else {
            map.put("info","保存失败");
            return map;
        }

    }


}

